<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use com\IpLocation;
class LogController extends Controller
{
	public function index(){
		
//		$lists=Db::name('admin_log')->order('add_time DESC')->select();
//		$Ip = new IpLocation('UTFWry.dat');
        $admin_id = session('admin_id');
        $id=Db::name('auth_group_access')->where('uid',$admin_id)->field('group_id')->find();
		$role = Db::name('auth_group')->field('id')->where('id',$id['group_id'])->find();
		$where=[];
		if($role['id']!=1){
			$where['admin_name']=session('admin_name');
		}
        $lists=Db::name('admin_log')->where($where)->order('add_time DESC')->paginate(8);
//      foreach($lists as $k=>$v){
//          $lists[$k]['ipaddr'] = $Ip->getlocation($lists[$k]['ip']);
//      }
//      
        $this->assign('list',$lists);
		 return $this->fetch();	
		}
	


    /**
     * [roleDel 删除]
     * @return [type] [description]
     */
    public function del_rule()
    {
        $id = input('param.id');
        if (Db::name('admin_log')->where('id',$id)->delete()) {
           return	toSuccess('删除成功');
        } else {
            return toError(408,'删除失败，请重新删除');
        }
    }	
}
?>